using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Text;
using yW5Lib;

namespace yWriter6
{
	public class clsExportNotes
	{
		public bool Export(ref clsProject cProject)
		{
			StringBuilder stringBuilder = new StringBuilder();
			string text = Path.Combine(cProject.ExportFolder(), "auto_project_notes.txt");
			bool result = default(bool);
			try
			{
				IEnumerator enumerator = default(IEnumerator);
				try
				{
					enumerator = cProject.Notes.GetEnumerator();
					while (enumerator.MoveNext())
					{
						clsNote clsNote = (clsNote)enumerator.Current;
						stringBuilder.AppendLine(clsNote.Title);
						stringBuilder.AppendLine(clsNote.DescText);
					}
				}
				finally
				{
					if (enumerator is IDisposable)
					{
						(enumerator as IDisposable).Dispose();
					}
				}
				try
				{
					clsShared.cFile.SaveTextFile(text, stringBuilder.ToString(), UseSystemEncoding: true);
					clsShared.cLang.TransMsgBox("Notes saved to @1@", MsgBoxStyle.OkOnly, "", text);
					result = true;
					return result;
				}
				catch (Exception ex)
				{
					ProjectData.SetProjectError(ex);
					Exception ex2 = ex;
					clsShared.cLang.TransMsgBox("Unable to save output file", MsgBoxStyle.Exclamation);
					clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
					ProjectData.ClearProjectError();
					return result;
				}
			}
			catch (Exception ex3)
			{
				ProjectData.SetProjectError(ex3);
				Exception ex4 = ex3;
				clsShared.cLog.AddAction(ex4, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}
	}
}
